#include #include #define TSIZE 45 // Á¦¸ñÀ» ÀúÀåÇÒ ¹è¿­ÀÇ Å©±â struct film { char title[TSIZE]; int rating; }; void main(void) { int n, i = 0; struct film * movies; // ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ printf("Enter the maximum number of movies you'll enter:\n"); scanf("%d", &n); // ½ÇÇàÁß¿¡ ¹è¿­ Å©±â¸¦ °áÁ¤ÇÏ¿© ¾µµ¥¾ø´Â ¸Þ¸ð¸® ³¶ºñ¸¦ ¸·´Â´Ù. movies = (struct film *) malloc(n * sizeof(struct film)); puts("Enter first movie title:"); while (i < n && gets(movies[i].title) != NULL && movies[i].title[0] != '\0') { puts("Enter your rating <0-10>:"); scanf("%d", &movies[i++].rating); while (getchar() != '\n') // rating ÀÔ·Â ÈÄ °³Çà ¹®ÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÔ·ÂµÇ¸é ¹«½ÃµÈ´Ù. continue; puts("Enter next movie title (empty line to stop):"); } if (i == 0) printf("No data entered. "); else puts("Here is the movie list:"); for (int j = 0; j < i; j++) printf("Movie: %s, Rating: %d\n", movies[j].title, movies[j].rating); puts("Bye!"); }